<?php
class App_Admin_Service_Plugin
{
	/**
	 * @var App_Admin_Model_Plugin
	 */
	protected $_modelPlugin;
	
	/**
	 * @return void
	 */
	public function __construct() 
	{
		$this->_modelPlugin = Main_Model::factory('Admin_Model_Plugin');	
	}
	
	/**
	 * @var App_Admin_Model_Plugin
	 */
	public function getModelPlugin()
	{
		return $this->_modelPlugin;
	}
	
	/**
	 * @param array $data
	 * @return bool
	 */
	public function insertItem($data)
	{
		$langId = Zend_Registry::getInstance()->langId;
		$data += array('lang_id' => $langId);
		return $this->_modelPlugin->insertItem($data);
	}
	
	/**
	 * @param array $data
	 * @param int $pluginId
	 * @return bool
	 */
	public function updateItem($data, $pluginId)
	{
		$langId = Zend_Registry::getInstance()->langId;
		$data += array('lang_id' => $langId);
		return $this->_modelPlugin->updateItem($data, $pluginId);
	}
	
	/**
	 * @param int $id
	 * @return array
	 */
	public function getItemById($id) 
	{
		$langId = Zend_Registry::getInstance()->langId;
		return $this->_modelPlugin->getItemById($id, $langId);
	}
	
	/**
	 * @param int $id
	 * @return bool
	 */
	public function deleteItem($id) 
	{
		return $this->_modelPlugin->deleteItem($id);
	}
	
/**
	 * @return array
	 */
	public function getAllIdAndName() 
	{
		$langId = Zend_Registry::getInstance()->langId;
		$list = $this->_modelPlugin->getAll($langId);
		$list = Main_Function::expandList($list, 'id', 'name');
		
		return $list;
	}
	
}
